#!/bin/bash

echo "🚀 手机文件上传工具 - macOS/Linux 安装脚本"
echo "==========================================="
echo ""

# 检查Node.js
if ! command -v node &> /dev/null; then
    echo "❌ 未检测到 Node.js，请先安装 Node.js"
    echo "   macOS: brew install node"
    echo "   Ubuntu: sudo apt install nodejs npm"
    echo "   下载地址: https://nodejs.org/"
    exit 1
fi

echo "✅ Node.js 已安装"
node --version

# 检查npm
if ! command -v npm &> /dev/null; then
    echo "❌ npm 不可用"
    exit 1
fi

echo "✅ npm 已安装"
npm --version
echo ""

echo "📦 正在安装依赖包..."
npm install

if [ $? -ne 0 ]; then
    echo "❌ 依赖安装失败"
    exit 1
fi

echo ""
echo "⚙️ 开始初始化配置..."
node setup.js

echo ""
echo "🎉 安装完成！"
echo ""
echo "使用方法:"
echo "  运行: ./run.sh 或 npm start"
echo ""

# 给run.sh执行权限
chmod +x run.sh 